<?php

class Application_Form_Element_ProductOfferSelect extends Zend_Form_Element_Select {
	
	public function init() {
		
		$productMapper = new Application_Model_ProductMapper();
		$offerMapper = new Application_Model_OfferMapper();
		$allProductIdsWithOffers = $offerMapper->fetchAllProductIdsWithOffers();
		
		$this->addMultiOption(0, 'Produs...');
		
		foreach ($productMapper->fetchAll() as $product) {
			if (!in_array($product->getId(), $allProductIdsWithOffers)){
				$this->addMultiOption($product->getId(), $product->getName());
			}
		}
		
		$this->setLabel('Produs:');
		$this->setName('id_product');
	}
}